<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>登录</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="__ADMIN__/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="__ADMIN__/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="__ADMIN__/css/amazeui.min.css" />
    <link rel="stylesheet" href="__ADMIN__/css/amazeui.datatables.min.css" />
    <link rel="stylesheet" href="__ADMIN__/css/app.css">
    <script src="__ADMIN__/js/jquery.min.js"></script>
    <style type="text/css">
        .verify{position: relative;}
        .code{position: absolute;top: -18px;right: 0}
    </style>

</head>

<body data-type="login">
    <script src="__ADMIN__/js/theme.js"></script>
    <div class="am-g tpl-g">
        <!-- 风格切换 -->
        <div class="tpl-skiner">
            <div class="tpl-skiner-toggle am-icon-cog">
            </div>
            <div class="tpl-skiner-content">
                <div class="tpl-skiner-content-title">
                    选择主题
                </div>
                <div class="tpl-skiner-content-bar">
                    <span class="skiner-color skiner-white" data-color="theme-white"></span>
                    <span class="skiner-color skiner-black" data-color="theme-black"></span>
                </div>
            </div>
        </div>
        <div class="tpl-login">
            <div class="tpl-login-content">
                <div class="tpl-login-logo">

                </div>
                <form class="am-form tpl-form-line-form" id="login_form">
                    <div class="am-form-group">
                        <input type="text" class="tpl-form-input" name="name" id="name" placeholder="请输入账号">

                    </div>

                    <div class="am-form-group">
                        <input type="password" class="tpl-form-input" name="pwd" id="pwd" placeholder="请输入密码">

                    </div>

                    <div class="am-form-group verify">
                        <input type="text" class="tpl-form-input" name="verify" id="verify" placeholder="请输入验证码">
                        <div class="code" style="display: none;">{:captcha_img()}</div>

                    </div>
                    <div class="am-form-group tpl-login-remember-me">
                        <input id="remember-me" name="remember-me" value="1" type="checkbox">
                        <label for="remember-me">
                        记住密码
                         </label>

                    </div>
                    <div class="am-form-group">
                        <button type="button" id="btn-login" class="am-btn am-btn-primary  am-btn-block tpl-btn-bg-color-success  tpl-login-btn">登录</button>

                    </div>
                </form>
                <div class="am-alert am-alert-danger" id="error" style="display: none;">
                  
                </div>
            </div>
        </div>
    </div>
    <script src="__ADMIN__/js/amazeui.min.js"></script>
    <script src="__ADMIN__/js/app.js"></script>
    <script src="__ADMIN__/js/jquery.serializeJSON.js"></script>
    <script type="text/javascript">
        $('#verify').focus(function(){
            $('.code').show();
        })
        $('.code').click(function(){
            $(this).html('{:captcha_img()}')
        })
        $('#btn-login').click(function(){
            var formData = $("#login_form").serializeJSON();
            if(formData.name == ''){
                $('#error').show().text('账号不能为空')
                return
            }
            if(formData.name == '' || formData.pwd == ''){
                $('#error').show().text('密码不能为空')
                return
            } 
           $('#error').hide()
            $.ajax({    
                type:"post",    
                url:"/ajaxlogin",    
                data:formData,
                beforeSend:function(){
                    $('#btn-login').text('登录中...')
                },   
                success:function(data){ 
                    if(data.status !=2){
                        $('#error').show().text(data.msg)
                    }else{
                        window.location.href = data.msg;
                    }   
                },
                complete:function(){ 
                    $('#btn-login').text('登录')
                }    
            });
            
        }); 
    </script>

</body>
</html>